# extract fzf.tar.xz and create link in `/usr/bin`
# can't use alias because Non-interactive shell not `source ~/.zshrc`
if [ $OS = 'windows' ] && [ $ARCH = 'x64' ]; then
    tar -xJf $spath/plugins/fzf_windows_x64.tar.xz -C $tpath/plugins
    echo 'extracted fzf_windows_x64.tar.xz'
    [ -f "$tpath/plugins/fzf.exe" ] && rm -rf /usr/bin/fzf && ln -s "$tpath/plugins/fzf.exe" /usr/bin/fzf
elif [ $OS = 'macos' ] && [ $ARCH = 'arm64' ]; then
    tar -xJf $spath/plugins/fzf_macos_arm64.tar.xz -C $tpath/plugins
    echo 'extracted fzf_macos_arm64.tar.xz'
    [ -f "$tpath/plugins/fzf" ] && \
    sudo mkdir -p /usr/local/bin && \
    sudo rm -f /usr/local/bin/fzf && sudo cp "$tpath/plugins/fzf" /usr/local/bin && \
    sudo chmod 755 /usr/local/bin/fzf
elif [ $OS = 'linux' ] && [ $ARCH = 'x64' ]; then
    tar -xJf $spath/plugins/fzf_linux_x64.tar.xz -C $tpath/plugins
    echo 'extracted fzf_linux_x64.tar.xz'
    [ -f "$tpath/plugins/fzf" ] && chmod u+x "$tpath/plugins/fzf" && sudo rm -rf /usr/bin/fzf && sudo ln -s "$tpath/plugins/fzf" /usr/bin/fzf
else
    log_error 'fzf machine mismatch'
fi
